<template>
    <div>
       <input type="text" v-model="num1" >
       {{ symbol }}
       <input type="text" v-model="num2">
       {{ result }}
       <br>
       <button @click="changeFn('+')">+</button>
       <button @click="changeFn('-')">-</button>
       <button @click="changeFn('*')">*</button>
       <button @click="changeFn('/')">/</button>
       <button @click="resultNum('=')">=</button>
    </div>
  </template>
  
  <script>
  export default {
    data(){
      return{
        data(){
      return{
        num1: '',
        num2: '',
        symbol: '',
        result: '0'
      }
    },
    methods:{
      changeFn(sym){
        this.symbol = sym
    },
    resultNum(){
      if(this.num1 == '' || this.num2 == ''){
        this.num1 = parseInt(this.num2)
        this.num2 = parseInt(this.num1)
        alert('请输入两个数')
      }
      switch(this.symbol){
        case '+' : this.result = this.num1 + this.num2
        break
        case '-' : this.result = this.num1 + this.num2
        break
        case '*' : this.result = this.num1 + this.num2
        break
        case '/' : this.result = this.num1 + this.num2
        break
      }
    }
    }
    }
  }
  }
  </script>
  
  <style>
  
  </style>